// 评分尺度和评语，页面滚动，弹出页面是否可以关闭标识
var stafArray = new Array(),myiscroll,canHide = true;
var reportDate;
var report;
var EMPLID;
var EP_MANAGER1_ID;
var my_um;
var ewg;
var detailLen;
var gradeInfo;//评分
var commment;//评分标准
var blns = [];//是否可编辑
var name;
var employeeId;
$(document).ready(function(){
	$(window).resize(function(){//当窗口大小改变时自动重新计算
		iscroll();
//		myiscroll.refresh();
	});
	// 初始化页面所有参数
	/*
	var aUrl = location.href;
	var urlInfo = (aUrl.substr(aUrl.indexOf("?")+1)).split("&");
	employeeId = urlInfo[0].split("=")[1];
	reportDate = urlInfo[1].split("=")[1];
	var mm = reportDate.substr(5);
	name = urlInfo[2].split("=")[1];
		name = decodeURI(name,"utf-8");
	*/
	employeeId = getQueryParam("emplid");
	reportDate = getQueryParam("report_date");
	name = decodeURI(getQueryParam("name"),"utf-8");
	var mm = reportDate.substr(5);
	$("#reprotTitle").text(name+"的"+mm+"月汇报");// 设置报表的汇报人姓名和汇报月份
	$("#loadingText").show();//显示加载图片
	$("#content").hide();
	$("#FooterFixed").hide();
	// 初始化页面详细内容，先要取到标尺的对应关系内容然后进行页面内容的初始化
	initGradeStaff(employeeId,reportDate);
	//初始化点击事件
	initEvent();
	
});
//初始化页面
function initContent(employeeId,reportDate){
	$.ajax({
		type: "post",
		url: mpsurl+"/mobile/report/queryUnderlingReportGrade.do",
		dataType: "json",
		data: {method:"underlingGrade",underlingEmplid:employeeId,report_date:reportDate},
		success: function(data){
			$("#loadingText").hide();
			$("#content").show();
			var reportData = eval(data);
			if(reportData.resultCode == "500600"){
				$("#FooterFixed").show();
				var reportInfo = reportData.value;// 所有报表内容
				if(reportInfo != null){
					my_um = reportData.my_um;// 当前处理人账号
					EMPLID = reportData.my_emplid;
					report = reportInfo.report;
					var chinName = report.chinName;// 被审批下属名字
					var managerName1 = report.manager1_name;//第一审批人姓名
					var managerName2 = report.manager2_name;//第二审批人姓名
					var managerName3 = report.manager3_name;//第三审批人姓名
					EP_MANAGER1_ID = report.eP_MANAGER1_ID;
					var EP_MANAGER2_ID = report.eP_MANAGER2_ID;
					var EP_MANAGER3_ID = report.eP_MANAGER3_ID;
					$("#EP_APPRAISAL_ID").val(report.ep_appraisal_id);
					$("#EP_MANAGER1_ID").val(EP_MANAGER1_ID);
					$("#EP_MANAGER2_ID").val(EP_MANAGER2_ID);
					$("#EP_MANAGER3_ID").val(EP_MANAGER3_ID);
					$("#EP_TEMPLATE_ID").val(report.eP_TEMPLATE_ID);
					$("#EVA_GROUP_ID").val(report.eVA_GROUP_ID);
					$("#GRADED_CYC").val(report.gRADED_CYC);
					$("#MONTH_EP").val(report.eVA_MONTH_EP);
					$("#PAIC_MON_STATUS").val(report.pAIC_MON_STATUS);
					$("#YEAR_EP").val(report.yEAR_EP);// 设置评分提示语的名字和月份
					$("#staffName").text(chinName);
					$("#staffMonth").text(report.eVA_MONTH_EP);// 设置驳回时下属员工名字
					$("#rejectName").text(chinName);
					// 根据当前处理人显示已评分信息
					gradeInfo = reportInfo.reportGrade;
					var approveInfoArray = new Array();
					var grade51 = gradeInfo.assess1_grade5;
					var assess1 = gradeInfo.assess1;
					var grade52 = gradeInfo.assess2_grade5;
					var assess2 = gradeInfo.assess2;
					var grade53 = gradeInfo.assess3_grade5;
					var assess3 = gradeInfo.assess3;
					// 设置已保存的意见;设置标尺,数值,对应评语信息;封装显示评语信息
					if(EMPLID == EP_MANAGER1_ID){
						$("#J-Reject").show();
						if(assess1 != ""){ $("#assessMsg").text(assess1); }
						if(grade51 != ""&& stafArray.length > 0){ setInitStaff(grade51); }
						var i=0;
						if(report.ep_manager2_status == "Y"){
							approveInfoArray[i] = {"assessName":managerName2,"grade5":grade52,"assess":assess2.replace(/\n/g,"<br>")};
							i++;
						}
						if(report.ep_manager3_status == "Y"){
							approveInfoArray[i] = {"assessName":managerName3,"grade5":grade53,"assess":assess3.replace(/\n/g,"<br>")};
							i++;
						}
					}else if(EMPLID == EP_MANAGER2_ID){
						if(assess2 != ""){ $("#assessMsg").text(assess2); }
						if(grade52 != "" && stafArray.length > 0){ setInitStaff(grade52); }
						var i = 0 ;
						if(report.report_status == "APP"){
							approveInfoArray[i] = {"assessName":managerName1,"grade5":grade51,"assess":assess1.replace(/\n/g,"<br>")};
							i++;
						}
						if(report.ep_manager3_status == "Y"){
							approveInfoArray[i] = {"assessName":managerName3,"grade5":grade53,"assess":assess3.replace(/\n/g,"<br>")};
							i++;
						}
					}else if(EMPLID == EP_MANAGER3_ID){
						if(assess3 != ""){ $("#assessMsg").text(assess3); }
						if(grade53 != "" && stafArray.length > 0){ setInitStaff(grade53); }
						var i = 0 ;
						if(report.report_status == "APP"){
							approveInfoArray[i] = {"assessName":managerName1,"grade5":grade51,"assess":assess1.replace(/\n/g,"<br>")};
							i++;
						}
						if(report.ep_manager2_status == "Y"){
							approveInfoArray[i] = {"assessName":managerName2,"grade5":grade52,"assess":assess2.replace(/\n/g,"<br>")};
							i++;
						}
					}
//					 设置并显示已评分信息
					for(var k = 0;k < approveInfoArray.length;k ++){
						for(var pos in approveInfoArray[k]){
							if(pos == "assessName"){
								var gradeDetail = "<div class='row-info row-info-readonly single-row m-b18'>"+
									"<ul class='row-info-list'><li><div class='info-list-cont'>"+
									"<span id='assess1Name' class='fn-c-3580d5'>"+approveInfoArray[k]["assessName"]+"</span>"+
									"<span class='fn-c-999'>评分：</span>"+
									"<span id='assess1Grade' class='fn-c-3580d5'>"+approveInfoArray[k]["grade5"]+"</span>"+
									"<span class='fn-c-999'>分</span></div></li><li><div class='info-list-cont'>"+
									"<p style=\"word-break: break-all;\"><span class='fn-c-999'>意见：</span><span id='assess1'>"+approveInfoArray[k]["assess"]+"</span></p>" +
									"</div></li></ul></div>";
								$("#firstReview").append(gradeDetail);
							}
						}
					}
					$("#selfGrade").text(gradeInfo.self_grade5);// 设置自评分
					ewg = reportInfo.ewg;// 设置关键信息评分概要显示列表
					detailLen = ewg.length;
					if(detailLen==0||reportInfo.iscyc =="0"){//如果没有关键工作计划或者是非评分月则将其隐藏
						$("#gjxx").hide();
					}
					$("#detailLen").val(detailLen);
					for(var i = 0;i < detailLen;i ++){
						//判断是否可编辑
						var bln = false;
						if(EMPLID == EP_MANAGER1_ID){
							if(ewg[i].iscyc =="1"){
								if(ewg[i].ewg_status == "CO"&&ewg[i].ewg_status_app =="0"&&ewg[i].ewg_status_app1 !="2"){
										bln = false;
								}else{
									bln = true;
								}
							}
						}
						blns[i]=bln;
						console.log(blns.toString());
						var perWeight =ewg[i].ewg_weight;
						var weight = ((perWeight + "").indexOf(".") != -1) ? new Number(perWeight).toFixed(1) + "%":new Number(perWeight).toFixed(0) + "%";
						var perDetail = "<li>"+
			                    "<div class='score-table-td'>" +
			                    	"<div class='row-left-icon'>" +
									"<i>"+(i+1)+"</i>" +
									"<input type='hidden' id='selectionId"+i+"' value='"+ewg[i].ewg_section_id+"'/>" +
									"</div>" +
				                    "<div id='descr"+i+"' class='info-list-cont'>"+ewg[i].ewg_descr+"</div></div>"+
				                    "<div class='score-table-td'><label id='weightId"+i+"'>"+weight+"</label></div>" +
				                    "<div id='selfRating"+i+"' class='score-table-td'>"+ewg[i].ewg_self_rating+"</div>"+
				                    "<div class='score-table-td'>" +
				                    "<input type='text' onkeyup='countGrade(this);' id='inputGrade"+i+"'" +
			                    " class='ipt' placeholder='0~100' maxlength='3' onfocus=\"clr(this)\" value='"+ewg[i].ewg_oth_rating+"'";
						if(bln==true){
							perDetail += " /></div></li>";
						}else{
							perDetail += " readonly=\"true\"/></div></li>";
						}
						$("#workPlanDetail").append(perDetail);
					}
					var gread = gradeInfo.self_grade100;
					if(gread==""||gread==" "){
						gread = 0.0;
					}else{
						gread = parseFloat(gread).toFixed(1);
					}
					var totalContent = "<li><div class='score-table-td'></div><div class='score-table-td'>总评分</div>"+
		                "<div class='score-table-td'>"+gread+"</div><div class='score-table-td'><label id='otherTotaleGrade'>"+parseFloat(gradeInfo.assess1_grade100).toFixed(1)+"</label></div></li>";
					$("#workPlanDetail").append(totalContent);
					
					// 页面滑动
					resetContentSize();
				}
			}else{
				canHide = false;
				$("#content").hide();
				var tourl="/mobile/underlingReport/xslb-pingfen.html?underlingEmplid="
					+employeeId+"&report_date="+reportDate+"&name="+name;
				checkLogin(reportData.resultCode,tourl,reportData.resultMessage);
			}			
		},
		error: function(XMLHttpRequest,textStatus,errorThrown){
			$("#loadingText").hide();
			$("#content").hide();
			errorMask("网络连接异常");
		}
	});
}
//获得焦点时清空编辑框
function clr(obj){
	if($(obj).val()==""){
		$(obj).val("");
	}
}
// 初始化设置标尺和数值显示
function setInitStaff(grade5){
	var len = stafArray.length;
	for(var k = 0;k < len;k ++){
		var s1 = stafArray[k]["s1"];
		var s2 = stafArray[k]["s2"];
		if(grade5 >= s1 && grade5 < s2){
			$("#rating_descr").text(stafArray[k]["rating_descr"]);
			$("#opinionMsg").text(stafArray[k]["descr"]);
			$("#J-StaffNum").text(grade5);
			var offsetX = -101 - new Number(((grade5 - 2.7) * 100)).toFixed(0);
		    $("#J-Staff").find(".staff-img-move").css("left",offsetX);
			break;
		}
	}
}
/*
 * 初始化评分标尺,因为有可能单据是保存过后的单据，需要初始化评分和评语
 * 所以评分信息要在内容初始化前完成
 * 初始的评分放在页面数组
 * author sudeming
 */
function initGradeStaff(employeeId,reportDate){
	$.ajax({
		type: "post",
		url: mpsurl+"/mobile/report/queryGradePrompt.do",
		dataType: "json",
		data: {method:"getGradeStaff"},
		success: function(data){
			var gradeStaff = eval(data);
			var resultCode = gradeStaff.resultCode;
			if(resultCode == "500600"){
				commment = gradeStaff.value;
				var comLen = commment.length;
				if(comLen > 0){
					for(var i = 0;i < comLen;i ++){
						var startMark = commment[i].s1;
						var endMark = commment[i].s2;
						var descr = commment[i].descr;
						var rating_descr = commment[i].rating_descr;
						stafArray[i] = {"s1":startMark,"s2":endMark,"descr":descr,"rating_descr":rating_descr};
					}
				}
				// 初始化页面
				initContent(employeeId,reportDate);
			}else{
				canHide = false;
				$("#loadingText").hide();
				$("#content").hide();
				var tourl="/mobile/underlingReport/xslb-pingfen.html?underlingEmplid="
					+employeeId+"&report_date="+reportDate+"&name="+name;
				checkLogin(gradeStaff.resultCode,tourl,gradeStaff.resultMessage);
			}
		},
		error: function(XMLHttpRequest,textStatus,errorThrown){
			$("#loadingText").hide();
			$("#content").hide();
			errorMask("网络连接异常");
		}
	});
}
/*
 * 总评分输入计算
 * 总评分的计算方法为：
 * 每个子项评分 X 对应的权重 = 个权重评分 
 * 个权重评分相加得到中评分
 * 总评分保留一位小数00.0格式
 * author sudeming 2014/03/11
 */
function countGrade(dom){
	// 每次输入100分评分后都需要重新计算总评分
	var len = $("#detailLen").val();
	$("#otherTotaleGrade").empty();
	var scor = $(dom).val();
	if(scor.length>1&scor.substring(0,1)=="0"){
		scor = scor.substring(1);
		$(dom).val(scor);
	}
	var t = /^((\d)|(\d{2})|(100))$/;
	if(!t.test(scor)){
		scor = scor.replace(/\D/,"");
		scor = scor.substring(0,scor.length-1);
		$(dom).val(scor);
		setAlamMsgForInput("请输入0~100之间的数",null);
	}
	
	var totalValue = 0;
	// 循环读取详细评分然后获取最后总评分
	for(var i = 0;i < len;i ++){
		var weightId = "#weightId" + i;
		var inputId = "#inputGrade" + i;
		var weightValue = $(weightId).text();
		var eachValue = $(inputId).val();
		var weight = 0;
		// 此处对输入错误和为空的列按0分计算，在提交的时候再对整个输入正确性进行校验
		if(isNaN(eachValue) || eachValue == ""){
			eachValue = 0;
		}
		if(weightValue == ""){
			weightValue = 0;
		}else{
			weight = parseFloat(weightValue.replace("%",""))*0.01;
		}
		totalValue += eachValue * weight;
	}
	$("#otherTotaleGrade").text(new Number(totalValue).toFixed(1));
}
function initEvent(){
	//保存
	$("#J-BtnSave").on("tap",function(){
		//保存选择框显示
//		if(validateLen()){
			$("#SaveMask").show();
//		}
	});
	//取消保存
	$("#CancelBtn").on("tap", function(){
		$("#SaveMask").hide();
	});
	//确定保存
	$("#SaveBtn").on("tap", function(){
		$("#SaveMask").hide();
		maskSubmit("save");
	});
	//驳回
	$("#J-Reject").on("tap", function(event){
//		if(validateLen()){
			$("#RejectMask").show();
//		}
	});
	//取消驳回
	$("#RejectBtnCancel").on("tap", function(event){
		$("#RejectMask").hide();
	});
	//确定驳回
	$("#RejectBtnSubmit").on("tap", function(event){
		$("#RejectMask").hide();
		maskSubmit("reject");
	});
	//提交
	$("#J-Submit").on("tap", function(){
		if(dataValidate()){
			$("#GlobalMask").show();
		}
	});
	//取消提交
	$("#MaskBtnCancel").on("tap", function(){
	    $("#GlobalMask").hide();
	});
	//确认提交
	$("#MaskBtnSubmit").on("tap", function(){
		$("#GlobalMask").hide();
		maskSubmit("submit");
	});
	//返回上页
	$("#back").on("tap",function(){
		var aUrl = location.href;
		var urlInfo = aUrl.substr(aUrl.indexOf("?"));
		//location.href="xslb-chakan.html" + urlInfo;
		var param = "emplid="+employeeId+"&report_date="+reportDate+"&name="+name;
		gotoLocation("/mobile/underlingReport/xslb-chakan.html",param);
	});
}

// 验证输入意见的长度;
function validateLen(){
	var assessMsg = $("#assessMsg").val().trim();
	var opinionArray = assessMsg.split("");
	var count = 0;
	for(var i = 0;i < opinionArray.length;i ++){
		if(opinionArray[i].charCodeAt(0) < 299){
			count ++;
		}else{
			count +=2;
		}
	}
	if(count < 10){
		var obj = document.getElementById("assessMsg");
		setAlamMsgForInput("考核人评价不能少于10个字，请详细评价.",obj);
		return false;
	}
	return true;
}

/*
 * 提交时数据验证
 * 需要对详细评分进行输入正确性的校验，规则为不能大于100，不能输入数字，不能为空
 * 意见不能少于10个中文字符，英文不能少于20个字符
 * 标尺评分需要拖动评分
 * author sudeming
 */
function dataValidate(event){
	var flag = true;
	var obj;
	// 如何当前评审为主审的时候，需要对详细评分进行校验
	var len = $("#detailLen").val();
	for(var i = 0;i < len;i ++){
		if(blns[i]==false) continue;
		var inputId = "#inputGrade" + i;
		var eachValue = $(inputId).val();
		// 详细评分不能为空
		if(eachValue == "" || eachValue == null || eachValue == " "){
			var errorInputMsg = "请完成所有关键工作计划的评分再提交.";
			flag = false;
			obj = document.getElementById("inputGrade" + i);
			setAlamMsgForInput(errorInputMsg,obj);
			canHide = true;
			return;
		}
	}
	// 意见长度校验
	if(!validateLen()){
		flag = false;
		var obj = document.getElementById("assessMsg");
		canHide = true;
		setAlamMsgForInput("考核人评价不能少于10个字，请详细评价.",obj);
		return;
	}
	// 是否已经进行评分
	var gradeFlag = checkOpinion(); 
	if(!gradeFlag){
		flag = false;
		obj = document.getElementById("opinionMsg");
		setAlamMsgForInput("请拖动标尺对该下属的月度汇报评分.",obj);
		canHide = true;
		return;
	}
	return flag;
}
/*
 * 评价信息切换,切换规则
 * 当前标尺分数对应的评价信息分数区间为
 * 大于等于评价起始分，小于终止分
 * author sudeming
 */
function setOpinionMsg(fraction){
	fraction = new Number(fraction).toFixed(1);
	var len = stafArray.length;
	if(len > 0){
		for(var k = 0;k < len;k ++){
			var s1 = stafArray[k]["s1"];
			var s2 = stafArray[k]["s2"];
			var descr = stafArray[k]["descr"];
			var rating_descr = stafArray[k]["rating_descr"];
			if(fraction >= s1 && fraction < s2){
				$("#opinionMsg").text(descr);
				$("#rating_descr").text(rating_descr);
				break;
			}
		}
	}
}
/*
 * 判断是否对下属进行评价，判断规则为
 * 读取当前评语和评分
 * 获取当前评分的区间评语，对比评语是否一致，
 * 如果一致则认定已经评分
 * author sudeming
 */
function checkOpinion(){
	var staffGrade = $("#J-StaffNum").text();
	var staffMsg= $("#opinionMsg").text();
	var flag = false;
	var len = stafArray.length;
	for(var k = 0;k < len;k ++){
		var s1 = stafArray[k]["s1"];
		var s2 = stafArray[k]["s2"];
		var descr = stafArray[k]["descr"];
		if(staffGrade >= s1 && staffGrade < s2){
			if(descr == staffMsg){
				flag = true;
			}else{
				flag = false;
			}
			break;
		}
	}
	return flag;
}
/*
 * 提交时获取参数
 * 获取隐藏域主表信息，获取当前的评语和评分
 * 如果是主审需要获取当前的详细评分
 * author sudeming
 */
function maskSubmit(status){
	report = toUpp(report);//将key转换为大写
	for(var i = 0 ; i < ewg.length ; i ++){
		ewg[i]=toUpp(ewg[i]);
	}
	report.LASTUPDOPRID=my_um;
	report.EP_APPRAISAL_ID = report.EP_APPRAISAL_ID+"";
	report.MONTH_EP = report.EVA_MONTH_EP+"";
	report.EP_MANAGER2_STATUS = "";
	report.EP_MANAGER3_STATUS = "";
	//获得第一评审人意见和评分
	if(EMPLID == report.EP_MANAGER1_ID){
		//获得第一评审人评分
		for(var i = 0;i < detailLen;i ++){
			ewg[i].PAIC_EP_RESERVED3 = $("#inputGrade" + i).val();
			ewg[i].PAIC_OTH_RATING = $("#inputGrade" + i).val();
			ewg[i].EP_APPRAISAL_ID = report.EP_APPRAISAL_ID+"";
			ewg[i].MONTH_EP = report.EVA_MONTH_EP+"";
			ewg[i].SECTION_ID = ewg[i].EWG_SECTION_ID+"";
			ewg[i].YEAR_EP = report.YEAR_EP+""; 
		}
		//第一评审人的评分
		var grade = {
			EP_APPRAISAL_ID:report.EP_APPRAISAL_ID+"",//主表主键
			EP_RATING_MON_CHK:$("#J-StaffNum").text(),//主考核人评分-5分
			EP_RATING_MON_K1_A:$("#rating_descr").text(),//主考核人考核评分标准
			EP_RATING_MON_K1_B:$("#opinionMsg").text(),//主考核人考核评分标准描述
			EP_RATING_MON_K1_W:gradeInfo.assess1_w,//主考核人权重
			MONTH_EP:report.EVA_MONTH_EP,//月
			PAIC_EP_RESERVED3:$("#assessMsg").val(),//主考核人评价
			PAIC_SUM_OTH_RATE:$("#otherTotaleGrade").text(),//总分-100分
			YEAR_EP:report.YEAR_EP//年
		};
		if(status == "reject"){
			grade.EP_RATING_MON_CHK = "3.9";
			grade.EP_RATING_MON_K1_A="";
			grade.EP_RATING_MON_K1_B="";
			report.REPORT_STATUS = "BAC";//未提交USUB，待确认SUBM,已确认APP ，驳回：BAC，NON:未制定
			report.PAIC_MON_STATUS = "BAC";//未提交USUB，待确认SUBM,已确认APP ，驳回：BAC，NON:未制定
		}else if(status == "submit"){
			report.REPORT_STATUS = "APP";
			report.PAIC_MON_STATUS = "APP";
		}
		sendQuest(report,ewg,grade,status);
	}else if(EMPLID == report.EP_MANAGER2_ID){
		//获得第二评审人意见和评分
		var smn2 = {
			 EP_APPRAISAL_ID : report.EP_APPRAISAL_ID+"" ,
			 EP_RATING_MON_CH2 : $("#J-StaffNum").text() ,//第二考核人评分-5分
			 EP_RATING_MON_CH3 : "" ,//第三考核人评分-5分
			 EP_RATING_MON_K2_A : $("#rating_descr").text() ,//第二考核人考核评分标准
			 EP_RATING_MON_K2_B : $("#opinionMsg").text() ,//第二考核人考核评分标准描述
			 EP_RATING_MON_K2_W : gradeInfo.assess2_w+"" ,//第二考核人权重
			 EP_RATING_MON_K3_A : "" ,
			 EP_RATING_MON_K3_B : "" ,
			 EP_RATING_MON_K3_W : "" ,
			 MONTH_EP : report.EVA_MONTH_EP,
			 PAIC_EP_RESERVED4 : $("#assessMsg").val() ,//第二考核人评价
			 PAIC_EP_RESERVED5 : "" ,//第三考核人评价
			 YEAR_EP : report.YEAR_EP 
		};
		if(status == "save"){
			report.EP_MANAGER2_STATUS = " ";//保存为" "，提交为Y，否则为空
		}else if(status == "submit"){
			report.EP_MANAGER2_STATUS = "Y";
		}
		send2quest(report,smn2,status);
	}else if(EMPLID == report.EP_MANAGER3_ID){
		//获得第三评审人意见和评分
		var smn2 = {
			 EP_APPRAISAL_ID : report.EP_APPRAISAL_ID+"" ,
			 EP_RATING_MON_CH2 : "" ,
			 EP_RATING_MON_CH3 : $("#J-StaffNum").text() ,
			 EP_RATING_MON_K2_A : "" ,
			 EP_RATING_MON_K2_B : "" ,
			 EP_RATING_MON_K2_W : "" ,
			 EP_RATING_MON_K3_A : $("#rating_descr").text() ,
			 EP_RATING_MON_K3_B : $("#opinionMsg").text() ,
			 EP_RATING_MON_K3_W : gradeInfo.assess3_w+"" ,
			 MONTH_EP : report.EVA_MONTH_EP+"" ,
			 PAIC_EP_RESERVED4 : "" ,
			 PAIC_EP_RESERVED5 : $("#assessMsg").val() ,
			 YEAR_EP : report.YEAR_EP
		};
		if(status == "save"){
			report.EP_MANAGER3_STATUS = " ";//保存为" "，提交为Y，否则为空
		}else if(status == "submit"){
			report.EP_MANAGER3_STATUS = "Y";
		}
		send2quest(report,smn2,status);
	}
}
//第一评审人提交
function sendQuest(report,ewg,grade,status){
	$("#loadingText").show();//显示加载图片
	$.ajax({
		type: "post",
		url: mpsurl+"/mobile/report/isApproveFirst.do",
		dataType: "json",
		data: {method:"reportApprove",common:JSON.stringify(report),wt_list:JSON.stringify(ewg),smn:JSON.stringify(grade)},
		success: function(data){
			$("#loadingText").hide();//关闭加载图片
			data = eval(data);
			if(data.resultCode=="500600"){
				if(data.FLAG=="A"){//"FLAG":"A","HR_SSTEXT_TEXT":"更新成功！ (30001,90)",
					var msg=$("#reprotTitle").text();
					if(status == "save"){
						msg = msg + "保存成功";
					}else if(status == "reject"){
						msg = msg + "驳回成功";
					}else if(status == "submit"){
						msg = msg + "提交成功";
					}
					setAlamMsgForInput(msg,null);
					if(status == "reject"|| status =="submit"){
						setTimeout(function(){
							//location.href = "/mobile/underlingReport/xslb.html?report_date="+reportDate;
							var param = "report_date="+reportDate;
							gotoLocation("/mobile/underlingReport/xslb.html",param);
						},1500);
					}
				}else{
					var msg=$("#reprotTitle").text();
					if(status == "save"){
						msg = msg + "保存失败";
					}else if(status == "reject"){
						msg = msg + "驳回失败";
					}else if(status == "submit"){
						msg = msg + "提交失败";
					}
					setAlamMsgForInput(msg,null);
				}
			}else{
				if(data.resultCode=="500702" || data.resultCode=="500802" || data.resultCode=="500803"){
					var tourl="/mobile/underlingReport/xslb-pingfen.html?underlingEmplid="
						+employeeId+"&report_date="+reportDate+"&name="+name;
					checkLogin(data.resultCode,tourl,data.resultMessage);
				}else{
					setAlamMsgForInput(data.resultMessage,null);
				}
			}
		},
		error: function(XMLHttpRequest,textStatus,errorThrown){
			$("#loadingText").hide();//关闭加载图片
			setAlamMsgForInput("网络连接异常",null);
		}
	});
}
//第二三评审人提交
function send2quest(report,smn2,status){
	$("#loadingText").show();//显示加载图片
	$.ajax({
		type: "post",
		url: mpsurl+"/mobile/report/isApproveSecondly.do",
		dataType: "json",
		data: {method:"reportApprove",mon2:JSON.stringify(report),smn2:JSON.stringify(smn2)},
		success: function(data){
			$("#loadingText").hide();//关闭加载图片
			data = eval(data);
			if(data.resultCode=="500600"){
				if(data.FLAG=="A"){//"FLAG":"A","HR_SSTEXT_TEXT":"更新成功！ (30001,90)",
					var msg=$("#reprotTitle").text();
					if(status == "save"){
						msg = msg + "保存成功";
					}else if(status == "reject"){
						msg = msg + "驳回成功";
					}else if(status == "submit"){
						msg = msg + "提交成功";
					}
					setAlamMsgForInput(msg,null);
					if(status == "reject"|| status =="submit"){
						setTimeout(function(){
							//location.href = "/mobile/underlingReport/xslb.html?report_date="+reportDate;
							var param = "report_date="+reportDate;
							gotoLocation("/mobile/underlingReport/xslb.html",param);
						},1500);
					}
				}else{
					var msg=$("#reprotTitle").text();
					if(status == "save"){
						msg = msg + "保存失败";
					}else if(status == "reject"){
						msg = msg + "驳回失败";
					}else if(status == "submit"){
						msg = msg + "提交失败";
					}
					setAlamMsgForInput(msg,null);
				}
			}else{
				if(data.resultCode=="500702" || data.resultCode=="500802" || data.resultCode=="500803"){
					var tourl="/mobile/underlingReport/xslb-pingfen.html?underlingEmplid="
						+employeeId+"&report_date="+reportDate+"&name="+name;
					checkLogin(data.resultCode,tourl,data.resultMessage);
				}else{
					setAlamMsgForInput(data.resultMessage,null);
				}
			}
		},
		error: function(XMLHttpRequest,textStatus,errorThrown){
			$("#loadingText").hide();//关闭加载图片
			setAlamMsgForInput("网络连接异常",null);
		}
	});
}
// 重新计算和设置页面高度
function resetContentSize(){
	var wh = window.innerHeight-110-112;
	if(myiscroll instanceof iScroll){
		myiscroll.destroy();
	}
	$("#content").css("height",wh+"px");
	myiscroll = new iScroll("content",
		{
			useTransition:false,
			checkDOMChanges: true,
	        bounce:false
	    });
}
/*
 * 提示信息:用于页面校验时数据填写错误或则是没有正确填写数据时的提示
 * 如果是输入错误提示需要滚动到当前行并设置焦点
 * author sudeming
 */
function setAlamMsgForInput(msg,obj){
		var errormsg ="<div class=\"g-mask\" id=\"promptBox\" style=\"display:block\">" +
							"<div class=\"check-prompt\">" +
								"<div class=\"check-prompt-bg\"></div>" +
								"<div class=\"check-prompt-txt\">"+msg+"</div>" +
							"</div></div>";
		$("body").append(errormsg);
		setTimeout(function(){
			$("#promptBox").remove("slow");
		},2000);
		//如果obj不为空，则焦点定位到obj
		if(obj != null){
			obj.focus();
//			myiscroll.refresh();
			iscroll();
		}
}
// 页面提示信息隐藏方法
function hidePrompt(){
	$(document).on("tap", function(e){
		if(canHide){
			var eleInput = document.getElementById("alamBoxForInput");
			if(eleInput == e.target){
				$("#promptBox").remove("slow");
			}
		}
	});
}
//将对象中的key变为大写
function toUpp(obj){
	var obj1={};
	for(var it in obj){
		var name = it.toString().toUpperCase();
		obj1[name] = obj[it];
	}
	return obj1;
}
